﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicServer.Bugs;
using CommonCs;

namespace BugSysSolution.RequestAjaxPage
{
    public partial class MainPageAjaxPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String tag = Request["tag"] ?? String.Empty;
            if (tag == "getbuglist")
            {
                GetAllBugListByType();
            }
            if (tag == "ajaxpage")
            {
                GetBugListByIndex();
            }
        }

        private void GetAllBugListByType()
        {
            String tag = Request["bugtype"] ?? String.Empty;
            BugLogic bl = new BugLogic();

            Response.Write(Common.DataTableToJson(bl.GetBugsByType(Convert.ToInt32(tag))));
        }

        public void GetBugListByIndex()
        {
            String index = Request["index"] ?? String.Empty; 
            String size = Request["size"] ?? String.Empty;
            BugLogic bl = new BugLogic();
            Response.Write(Common.DataTableToJson(bl.GetBugsByIndex(Convert.ToInt32(index) - 1, Convert.ToInt32(size))));
        }
    }
}